﻿using System;

namespace _034_虚函数成员
{
    public class Asset
    {
        public string Name;
        public virtual decimal Liability { get { return 0; } }
    }
    public class Stock : Asset
    {
        public long SharesOwned;
    }
    public class House : Asset
    {
        public decimal Mortgage;
        public override decimal Liability
        {
            get { return Mortgage; }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            House mansion = new House { Name = "McMansion", Mortgage = 250000 };
            Asset a = mansion;
            Console.WriteLine(mansion.Liability); // 250000
            Console.WriteLine(a.Liability); // 250000

            Console.ReadKey();
        }
    }
}